package com.liveinstars.api.facade;

//import ddd.activity.application.service.LeaveApplicationService;
//import ddd.activity.domain.activity.entity.Leave;
//import ddd.activity.domain.person.entity.Person;
//import ddd.activity.infrastructure.common.api.Response;
//import ddd.activity.interfaces.assembler.LeaveAssembler;
//import ddd.activity.interfaces.dto.LeaveDTO;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.List;
//import java.util.stream.Collectors;
//
//@RestController
//@RequestMapping("/activity")
//@Slf4j
//public class LeaveApi {
//
//    @Autowired
//    LeaveApplicationService leaveApplicationService;
//
//    @PostMapping
//    public Response createLeaveInfo(LeaveDTO leaveDTO){
//        Leave activity = LeaveAssembler.toDO(leaveDTO);
//        leaveApplicationService.createLeaveInfo(activity);
//        return Response.ok();
//    }
//
//    @PutMapping
//    public Response updateLeaveInfo(LeaveDTO leaveDTO){
//        Leave activity = LeaveAssembler.toDO(leaveDTO);
//        leaveApplicationService.updateLeaveInfo(activity);
//        return Response.ok();
//    }
//
//    @PostMapping("/submit")
//    public Response submitApproval(LeaveDTO leaveDTO){
//        Leave activity = LeaveAssembler.toDO(leaveDTO);
//        leaveApplicationService.submitApproval(activity);
//        return Response.ok();
//    }
//
//    @PostMapping("/{leaveId}")
//    public Response findById(@PathVariable String leaveId){
//        Leave activity = leaveApplicationService.getLeaveInfo(leaveId);
//        return Response.ok(LeaveAssembler.toDTO(activity));
//    }
//
//    /**
//     * 根据申请人查询所有请假单
//     * @param applicantId
//     * @return
//     */
//    @PostMapping("/query/applicant/{applicantId}")
//    public Response queryByApplicant(@PathVariable String applicantId){
//        List<Leave> leaveList = leaveApplicationService.queryLeaveInfosByApplicant(applicantId);
//        List<LeaveDTO> leaveDTOList = leaveList.stream().map(activity -> LeaveAssembler.toDTO(activity)).collect(Collectors.toList());
//        return Response.ok(leaveDTOList);
//    }
//
//    /**
//     * 根据审批人id查询待审批请假单（待办任务）
//     * @param approverId
//     * @return
//     */
//    @PostMapping("/query/approver/{approverId}")
//    public Response queryByApprover(@PathVariable String approverId){
//        List<Leave> leaveList = leaveApplicationService.queryLeaveInfosByApprover(approverId);
//        List<LeaveDTO> leaveDTOList = leaveList.stream().map(activity -> LeaveAssembler.toDTO(activity)).collect(Collectors.toList());
//        return Response.ok(leaveDTOList);
//    }
//}
